<?php
// +----------------------------------------------------------------------
// | ebSIG
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.ebsig.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: liudaojian <liudaojian@ebsig.com>
// +----------------------------------------------------------------------

/**
 * 接口路由
 * @author   liudaojian <liudaojian@ebsig.com>
 * @version 1.0
 */

namespace App\Http\Routes;

use Illuminate\Contracts\Routing\Registrar;

class ApiRoutes
{

    public function map(Registrar $router)
    {

        $router->group(['prefix' => '/open-api/cps/'], function($router) {
            $router->get('fx/order', 'Api\CPS\FxOrderController@search');
            $router->get('test', 'Api\TestController@test');

        });

        $router->group([ 'middleware' => 'api.service', 'prefix' => '/open-api/'], function($router) {

            $router->get('sso', 'Api\SsoController@get');

            //小程序
            $router->post('applet/init', 'Api\Wx\WxAppletController@init');
            $router->get('applet/get', 'Api\Wx\WxAppletController@get');
            $router->get('wx/data/decrypt', 'Api\Wx\WxAppletController@decryptData');
            //小程序首页
            $router->get('wx/index', 'Api\Wx\WxAppletController@index');

            //微信会员卡
            $router->get('wx/card/check', 'Api\Wx\WxCustomerCardController@check');

            //门店
            $router->get('mall/lbs/init', 'Api\Mall\MallLbsController@init'); //附近门店初始化
            $router->get('mall/lbs/lately', 'Api\Mall\MallLbsController@lately'); //最近一家门店
            $router->get('mall/nearby', 'Api\Mall\MallLbsController@nearby'); //附近门店

            //会员路由
            $this->customer($router);

            //团购路由
            $this->tg($router);

            //订单
            $this->bill($router);

            //卡券
            $this->card($router);

            //非常购
            $this->flyGo($router);

            //秒杀
            $this->secKill($router);

            $this->alipay($router);

            //商品
            $this->goods($router);

            //结算
            $this->checkOut($router);

            //集点路由
            $this->jd($router);

            //对外接口路由
            $this->outWard($router);

        });

    }

    /**
     * 支付宝路由
     * @param $router
     */
    private function alipay($router)
    {

        $router->post('alipay/material/image/upload', 'Api\Alipay\AlipayRequestController@materialImageUpload'); //上传图片
        $router->post('alipay/card/template/create', 'Api\Alipay\AlipayRequestController@cardTemplateCreate'); //创建会员卡模板
        $router->post('alipay/card/template/modify', 'Api\Alipay\AlipayRequestController@cardTemplateModify'); //修改会员卡模板
        $router->post('alipay/card/formtemplate/set', 'Api\Alipay\AlipayRequestController@cardFormtemplateSet'); //会员卡开卡表单模板配置
        $router->post('alipay/card/activateurl/apply', 'Api\Alipay\AlipayRequestController@cardActivateurlApply'); //获取会员卡领卡投放链接
        $router->post('alipay/card/activateform/query', 'Api\Alipay\AlipayRequestController@cardActivateformQuery'); //查询用户提交的会员卡表单信息

        $router->post('alipay/market/shop/batchquery', 'Api\Alipay\AlipayRequestController@marketShopBatchquery'); //查询商户的门店编号列表
        $router->post('alipay/market/shop/querydetail', 'Api\Alipay\AlipayRequestController@marketShopQueryDetail'); //查询单个门店信息接口

    }

    /**
     * 团购路由
     * @param $router
     */
    public function tg( $router )
    {
        //团购
        $router->get('tg/init', 'Api\Tg\TgController@init');   //团购列表初始化接口
        $router->get('tg/search/list', 'Api\Tg\TgController@search');   //团购列表查询接口
        $router->get('tg/detail', 'Api\Tg\TgController@detail');   //团购详情
        $router->get('tg/participate','Api\Tg\TgController@participate');   //参团接口


        $router->get('tg/add/cart','Api\Tg\TgCartController@addCart');   //加入购物车接口
        $router->get('tg/choose/address','Api\Tg\TgCheckoutController@chooseAddress');   //选择收货地址
        $router->get('tg/use/points','Api\Tg\TgCheckoutController@usePoints');   //使用积分
        $router->get('tg/use/balance','Api\Tg\TgCheckoutController@useBalance');   //使用余额
        $router->get('tg/cancel/use/points','Api\Tg\TgCheckoutController@cancelUsePoints');   //取消使用积分
        $router->get('tg/cancel/use/balance','Api\Tg\TgCheckoutController@cancelUseBalance');   //取消使用余额

        $router->get('tg/check', 'Api\Tg\TgCheckoutController@init');   //团购结算初始化接口

        $router->get('tg/submit', 'Api\Tg\TgBillSubmitController@billSubmit');   //团购提交订单接口

        $router->get('tg/pay', 'Api\Tg\TgBillSubmitController@checkPay');   //团购检查支付

        $router->get('tg/check/pay/pwd', 'Api\Tg\TgCheckoutController@checkPayPwd');   //检查支付密码

        //支付
        $router->get('tg/tuan/pay','Api\Tg\TgCheckoutController@tuanPay');   //支付详情

    }

    /**
     * 会员路由
     * @param $router
     */
    public function customer( $router )
    {

        $router->get('customer/init', 'Api\Customer\CustomerController@init');  //小程序会员信息接口
        $router->get('customer/login/init', 'Api\Customer\CustomerLoginController@setting');  //登录页初始化接口
        $router->get('customer/check/mobile', 'Api\Customer\CustomerController@checkMobile');  //手机号查询会员是否存在
        $router->get('customer/quick/login', 'Api\Customer\CustomerLoginController@quickLogin');  //手机快捷登录
        $router->get('customer/mobile/login', 'Api\Customer\CustomerController@mobileLogin');  //手机号+ 短信验证码登录
        $router->get('customer/login', 'Api\Customer\CustomerController@login');  //账户+ 密码登录
        $router->get('customer/register', 'Api\Customer\CustomerController@register');  //会员注册
        $router->get('customer/wx/login', 'Api\Customer\CustomerLoginController@wxLogin');  //微信登录

        $router->get('customer/points', 'Api\Customer\CustomerAccountController@points');  //会员积分查询接口
        $router->get('customer/points/logs', 'Api\Customer\CustomerAccountController@pointsLogs');  //会员积分明细接口
        $router->get('customer/balance', 'Api\Customer\CustomerAccountController@balance');  //会员余额查询接口
        $router->get('customer/balance/logs', 'Api\Customer\CustomerAccountController@balanceLogs');  //会员余额明细接口

        $router->get('customer/card/init', 'Api\Customer\CustomerCardController@init');  //卡券列表初始化
        $router->get('customer/card/list', 'Api\Customer\CustomerCardController@search');  //卡券列表页获取卡券信息
        $router->get('customer/card/detail', 'Api\Customer\CustomerCardController@detail');  //卡券详情页
        $router->get('customer/card/verify', 'Api\Customer\CustomerCardController@verify');  //卡券核销接口
        $router->get('customer/card/give', 'Api\Customer\CustomerCardController@give');  //卡券转赠接口

        $router->get('customer/deliver/search', 'Api\Customer\CustomerDeliverController@search');  //会员收货地址列表
        $router->get('customer/deliver/detail', 'Api\Customer\CustomerDeliverController@detail');  //获取收货地址详情
        $router->get('customer/deliver/set/default', 'Api\Customer\CustomerDeliverController@setDefault');  //设置默认收获地址
        $router->get('customer/deliver/edit', 'Api\Customer\CustomerDeliverController@edit');  //添加、修改会员收货地址
        $router->get('customer/deliver/del', 'Api\Customer\CustomerDeliverController@del');  //删除会员收货地址

        $router->get('customer/recharge/init', 'Api\Customer\CustomerRechargeController@init');   //充值初始化
        $router->get('customer/recharge/online/pay', 'Api\Customer\CustomerRechargeController@onlinePay');   //在线充值
        $router->get('customer/recharge/card/init', 'Api\Customer\CustomerRechargeController@rechargeCardInit');   //充值卡页面初始化
        $router->get('offline/recharge/card', 'Api\Customer\CustomerRechargeController@searchOfflineRechargeCard'); //查询线下充值卡信息
        $router->get('customer/recharge/card/pay', 'Api\Customer\CustomerRechargeController@cardPay'); //充值卡充值
        $router->get('customer/recharge/log', 'Api\Customer\CustomerRechargeController@rechargeLog'); //充值记录


    }

    /**
     * 订单
     * @param $router
     */
    public function bill($router)
    {

        $router->get('order/init', 'Api\Order\BillController@init');  //小程序订单取消原因
        $router->get('order/search', 'Api\Order\BillController@search');  //小程序订单列表接口
        $router->get('order/detail', 'Api\Order\BillController@detail');  //小程序订单详情
        $router->get('order/trace', 'Api\Order\BillController@trace');  //小程序订单轨迹
        $router->get('order/barcode', 'Api\Order\BillController@barcode');  //小程序订单提货券接口
        $router->get('order/cancel', 'Api\Order\BillController@cancel');  //小程序订单取消
        $router->get('order/check/bill/pay', 'Api\Order\BillController@checkBillPay');  //小程序检查订单和支付
        $router->get('order/submit', 'Api\Order\BillSubmitController@billSubmit');  //小程序提交订单


        //对外订单类接口
        $router->post('order/delivery', 'Api\Order\OutwardOrderController@delivery');  //订单配送接口（订单发货）
        $router->post('order/finish', 'Api\Order\OutwardOrderController@finish');  //订单完成接口
        $router->post('order/fast/finish', 'Api\Order\OutwardOrderController@fastFinish');  //订单快速完成接口
        $router->post('order/fast/barcode/finish', 'Api\Order\OutwardOrderController@fastBarcodeFinish');  //订单快速完成接口(提货码)
        $router->post('order/cancel', 'Api\Order\OutwardOrderController@cancel');  //订单取消接口
        $router->post('order/search/get', 'Api\Order\OutwardOrderController@get');  //获取订单接口
        $router->post('order/batch/search/get', 'Api\Order\OutwardOrderController@batchGet');  //批量获取订单接口
        $router->post('order/return/get', 'Api\Order\OutwardOrderController@returnGet');  //获取退货单接口
        $router->post('order/return/audit', 'Api\Order\OutwardOrderController@returnAudit');  //退货单审核接口
        $router->post('order/return/cancel', 'Api\Order\OutwardOrderController@returnCancel');  //退货单取消接口
        $router->post('order/return/finish', 'Api\Order\OutwardOrderController@returnFinish');  //退货单完成接口
        $router->post('order/return/fast/finish', 'Api\Order\OutwardOrderController@returnFastFinish');  //退货单快速完成接口

    }

    /**
     * 卡券
     * @param $router
     */
    public function card($router)
    {

        $router->get('card/center/init', 'Api\Card\CardController@init');  //小程序券中心初始化接口
        $router->get('card/center/list', 'Api\Card\CardController@search');  //小程序券中心列表接口
        $router->get('card/center/detail', 'Api\Card\CardController@detail');  //小程序券中心详情接口
        $router->get('card/center/receive', 'Api\Card\CardController@receive');  //小程序券中心领取接口
        $router->get('card/center/success', 'Api\Card\CardController@success');  //小程序券中心领取成功页
        $router->get('card/center/checkout', 'Api\Card\CheckoutController@checkout');  //小程序券中心结算页
        $router->get('card/center/couponsBuy', 'Api\Card\CheckoutController@couponsBuy');  //小程序券中心结算接口



        //对外卡券类接口
        $router->post('card/search/get', 'Api\Card\OutwardCardController@get');  //卡券信息查询接口
        $router->post('card/search/list', 'Api\Card\OutwardCardController@getList');  //会员卡券列表查询接口
        $router->post('card/code/upload', 'Api\Card\OutwardCardController@codeUpload');  //券码同步接口
        $router->post('card/code/batch/grant', 'Api\Card\OutwardCardController@batchGrant');  //券码批量发放接口


    }

    /**
     * 非常购
     * @param $router
     */
    public function flyGo($router)
    {
        $router->get('flygo/mall/list', 'Api\Mall\MallLbsController@nearby');    //门店查询
        $router->get('flygo/goods/search', 'Api\FlyGo\GoodsController@search');    //商品查询
        $router->get('flygo/customer/login', 'Api\FlyGo\CustomerController@login');    //登录
        $router->get('flygo/customer/register', 'Api\FlyGo\CustomerController@register');    //绑定注册
        $router->get('flygo/member/index', 'Api\FlyGo\MemberCenterController@index');    //会员中心
        $router->get('flygo/member/edit', 'Api\FlyGo\MemberCenterController@edit');    //修改会员资料
        $router->get('flygo/member/search', 'Api\FlyGo\MemberCenterController@search');       //订单查询
        $router->get('flygo/member/detail', 'Api\FlyGo\MemberCenterController@detail');       //订单详情
        $router->get('flygo/member/cancel', 'Api\FlyGo\MemberCenterController@cancel');       //订单取消
       // $router->get('flygo/member/del', 'Api\FlyGo\MemberCenterController@delete');          //订单删除
        $router->get('flygo/member/list', 'Api\FlyGo\MemberCenterController@couponlist');          //订单删除
        $router->get('flygo/goods/add', 'Api\FlyGo\CartController@add');   //商品加入购物车
        $router->get('flygo/goods/del', 'Api\FlyGo\CartController@del');   //删除购物车商品
        $router->get('flygo/bag/add', 'Api\FlyGo\CartController@addShoppingBag');   //购物袋加入购物车
        $router->get('flygo/bag/del', 'Api\FlyGo\CartController@delShoppingBag');   //购物袋删除
        $router->get('flygo/cart/init', 'Api\FlyGo\CartController@index');   //购物袋初始化
        $router->get('flygo/coupon/use', 'Api\FlyGo\CartController@use_coupon');   //使用优惠券
        $router->get('flygo/coupon/cancel', 'Api\FlyGo\CartController@cancel_coupon');   //取消优惠券
        $router->get('flygo/order/save', 'Api\FlyGo\BillController@orderFormat');   //提交订单
        $router->get('flygo/pay/parameter', 'Api\FlyGo\PayController@weixinAppletPay');   //获取小程序支付参数




        $router->get('flygo/test/getredis', 'Api\FlyGo\CartController@getredis');

    }

    
    /**
     * 秒杀路由
     * @param $router
     */
    public function secKill( $router )
    {
        //秒杀
        $router->get('promotion/init', 'Api\Promotion\SeckillController@init'); //秒杀列表初始化
        $router->get('promotion/add/cart', 'Api\Promotion\SeckillCartController@add'); //秒杀加入购物车
        $router->get('promotion/checkout/init', 'Api\Promotion\SeckillCheckoutController@init'); //秒杀结算初始化
        $router->get('promotion/choose/address','Api\Promotion\SeckillCheckoutController@chooseAddress');   //选择收货地址
        $router->get('promotion/use/points','Api\Promotion\SeckillCheckoutController@usePoints');   //使用积分
        $router->get('promotion/use/balance','Api\Promotion\SeckillCheckoutController@useBalance');   //使用余额
        $router->get('promotion/cancel/use/points','Api\Promotion\SeckillCheckoutController@cancelUsePoints');   //取消使用积分
        $router->get('promotion/cancel/use/balance','Api\Promotion\SeckillCheckoutController@cancelUseBalance');   //取消使用余额
        $router->get('promotion/submit', 'Api\Promotion\SeckillBillSubmitController@billSubmit');   //秒杀提交订单接口
        $router->get('promotion/check/pay/pwd', 'Api\Promotion\SeckillCheckoutController@checkPayPwd');   //检查支付密码

    }

    /**
     * 商品路由
     * @param $router
     */
    public function goods( $router )
    {
        //商品列表，搜索
        $router->get('goods/list/init', 'Api\Goods\GoodsController@listInit');
        $router->get('goods/list', 'Api\Goods\GoodsController@search');

        //商品详情
        $router->get('goods/init', 'Api\Goods\GoodsController@goodsInit'); //商品详情初始化
        $router->get('goods/detail', 'Api\Goods\GoodsController@detail'); //商品规格
        $router->get('goods/comments/list', 'Api\Goods\CommentsController@search'); //商品评论
        ///商品分类
        $router->get('goods/category','Api\Goods\CategoryController@init');

        
        //商品收藏
        $router->get('collect/add','Api\Goods\CollectController@add');
        $router->get('collect/del','Api\Goods\CollectController@del');

        //购物车
        $router->get('cart/add', 'Api\Cart\CartController@addGeneral');
        $router->get('cart/buy', 'Api\Cart\CartController@nowBuy');
        $router->get('cart/init', 'Api\Cart\CartController@init'); //购物车初始化接口
        $router->get('cart/update', 'Api\Cart\CartController@upGeneralGoods'); //修改购物车商品数量
        $router->get('cart/del', 'Api\Cart\CartController@delGeneralGoods'); //删除购物车商品
        $router->get('cart/choose/buy', 'Api\Cart\CartController@isBuy'); //选择或取消购物车商品
        $router->get('cart/check', 'Api\Cart\CartController@check'); //检查购物车


        //对外商品类接口
        $router->post('product/batch/add', 'Api\Goods\OutwardBatchController@addProduct'); //批量新增商品接口
        $router->post('product/stock/batch/store', 'Api\Goods\OutwardBatchController@storeStock'); //批量保存商品库存接口
        $router->post('product/price/batch/update', 'Api\Goods\OutwardBatchController@updatePrice'); //批量更新商品价格接口

    }

    /**
     * 结算路由
     * @param $router
     */
    public function checkOut( $router )
    {
        //初始化
        $router->get('checkout/init', 'Api\Checkout\CheckoutController@init');
        //切换配送方式/选择收货地址
        $router->get('checkout/choose/address', 'Api\Checkout\CheckoutController@chooseAddress');
        //切换支付类型
        $router->get('checkout/choose/paytype', 'Api\Checkout\CheckoutController@choosePayType');
        //使用积分
        $router->get('checkout/use/points', 'Api\Checkout\CheckoutController@usePoints');
        //使用余额
        $router->get('checkout/use/balance', 'Api\Checkout\CheckoutController@useBalance');
        //使用卡券
        $router->get('checkout/use/coupon', 'Api\Checkout\CheckoutController@useCoupon');
        //取消使用积分
        $router->get('checkout/cancel/points', 'Api\Checkout\CheckoutController@cancelUsePoints');
        //取消使用余额
        $router->get('checkout/cancel/balance', 'Api\Checkout\CheckoutController@cancelUseBalance');
        //取消使用卡券
        $router->get('checkout/cancel/coupon', 'Api\Checkout\CheckoutController@cancelCoupon');
        //验证支付密码
        $router->get('checkout/check/pwd', 'Api\Checkout\CheckoutController@checkPayPwd');
        //激活卡券
        $router->get('checkout/active/coupon', 'Api\Checkout\CheckoutController@activeCoupon');


    }

    //集点
    private function jd($router) {

        $router->get('jd/list', 'Api\Activity\JdController@init');   //列表
        $router->get('jd/detail', 'Api\Activity\JdController@detail');   //详情
        $router->get('jd/give', 'Api\Activity\JdController@give');   //转增页
        $router->post('jd/give/send', 'Api\Activity\JdController@giveSend');   //转增页
        $router->get('jd/prize', 'Api\Activity\JdController@prize');   //奖品页
        $router->post('jd/prize/exchange', 'Api\Activity\JdController@packageExchange');   //奖品兑换

    }


    /**
     * 对外接口
     * @param $router
     */
    private function outWard($router) {

        //对外会员类接口
        $router->get('member/account/search', 'Api\Outward\CustomerAccountController@search');  //会员账户查询接口
        $router->get('member/account/points/add', 'Api\Outward\CustomerAccountController@pointsAdd');  //会员增加积分接口
        $router->get('member/account/points/reduction', 'Api\Outward\CustomerAccountController@pointsReduction');  //会员扣减积分接口
        $router->get('member/account/balance/recharge', 'Api\Outward\CustomerAccountController@recharge');  //会员余额充值接口
        $router->get('member/account/balance/consumption', 'Api\Outward\CustomerAccountController@consumption');  //会员余额消费接口
        $router->get('member/account/logs', 'Api\Outward\CustomerAccountController@accountLogs');  //会员账户记录接口

    }
}